package com.lly.songhigh.view;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.lly.songhigh.R;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by dllo on 15/10/12.
 */
public class SelectDialog extends AlertDialog implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {
    @Bind(R.id.time_item_radio_btn_nosleep)
    RadioButton timeItemRadioBtnNosleep;
    @Bind(R.id.time_item_radio_btn_10)
    RadioButton timeItemRadioBtn10;
    @Bind(R.id.time_item_radio_btn_20)
    RadioButton timeItemRadioBtn20;
    @Bind(R.id.time_item_radio_btn_30)
    RadioButton timeItemRadioBtn30;
    @Bind(R.id.time_item_radio_btn_45)
    RadioButton timeItemRadioBtn45;
    @Bind(R.id.time_item_radio_btn_60)
    RadioButton timeItemRadioBtn60;
    @Bind(R.id.time_item_radio_group)
    RadioGroup timeItemRadioGroup;
    private Context context;
    private LeaveMyDialogListener listener;
    private RadioButtonListener onCheckedChangedListener;

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        onCheckedChangedListener.OnCheckedChanged(group, checkedId);
    }


    public interface LeaveMyDialogListener {
        public void onClick(View view);
    }

    public interface RadioButtonListener {
        public void OnCheckedChanged(RadioGroup group, int checkedId);
    }

    protected SelectDialog(Context context) {
        super(context);
    }

    public SelectDialog(Context context, int theme, RadioButtonListener onCheckedChangedListener) {
        super(context, theme);
        this.context = context;
        this.onCheckedChangedListener = onCheckedChangedListener;
    }

    protected SelectDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.time_item);
        ButterKnife.bind(this);
//        timeItemRadioBtnNosleep.setOnClickListener(this);
//        timeItemRadioBtn10.setOnClickListener(this);
//        timeItemRadioBtn20.setOnClickListener(this);
//        timeItemRadioBtn30.setOnClickListener(this);
//        timeItemRadioBtn45.setOnClickListener(this);
//        timeItemRadioBtn60.setOnClickListener(this);
        timeItemRadioGroup.setOnCheckedChangeListener(this);
    }

    @Override
    public void onClick(View v) {
        listener.onClick(v);
    }
}
